/*
 * jxDao Project (2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxDao.dao.exception;

import java.sql.SQLException;

import org.jxUtils.check.CheckUtil;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxDao
 * @package org.jxDao.dao.exception
 * @date 17/05/2014 - 17:45:43
 */
public class JXDaoException extends SQLException {
	
	private static final long serialVersionUID = -2139923660385313520L;
	
	private String sql;
	
	/**
	 * 
	 */
	public JXDaoException() {
	
		super();
	}
	
	/**
	 * @param reason
	 */
	public JXDaoException(final String reason) {
	
		super(reason);
	}
	
	/**
	 * @param reason
	 * @param SQLState
	 */
	public JXDaoException(final String reason, final String SQLState) {
	
		super(reason, SQLState);
	}
	
	/**
	 * @param reason
	 * @param SQLState
	 * @param vendorCode
	 */
	public JXDaoException(final String reason, final String SQLState, final int vendorCode) {
	
		super(reason, SQLState, vendorCode);
	}
	
	/**
	 * @param reason
	 * @param sqlState
	 * @param vendorCode
	 * @param cause
	 */
	public JXDaoException(final String reason, final String sqlState, final int vendorCode, final Throwable cause) {
	
		super(reason, sqlState, vendorCode, cause);
	}
	
	/**
	 * @param reason
	 * @param sqlState
	 * @param cause
	 */
	public JXDaoException(final String reason, final String sqlState, final Throwable cause) {
	
		super(reason, sqlState, cause);
	}
	
	/**
	 * @param reason
	 * @param cause
	 */
	public JXDaoException(final String reason, final Throwable cause) {
	
		super(reason, cause);
	}
	
	/**
	 * @param cause
	 */
	public JXDaoException(final Throwable cause) {
	
		super(cause);
	}
	
	/**
	 * @return the sql
	 */
	public final String getSQL() {
	
		return sql;
	}
	
	/**
	 * @param sql
	 *        the sql to set
	 */
	public final void setSQL(final String sql) {
	
		this.sql = sql;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Throwable#toString()
	 */
	@Override
	public String toString() {
	
		return 
			"\n\n" + getMessage() + 
			(CheckUtil.isNotNullAndNotAbsoluteEmpty(getSQL()) ? "\n\nSQL: " + getSQL() + "\n" : "");
	}
}
